package com.slipper.core.file.config;

import com.slipper.core.file.IFileService;
import com.slipper.core.file.local.LocalFileService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty(name = "file.storage.mode", havingValue = "local")
public class LocalFileServiceConfiguration {
    @Value("${local.save.mode}")
    private String localSaveMode;
    @Value("${local.save.path}")
    private String localSavePath;

    @Bean("fileService")
    public IFileService localFileService() {
        return new LocalFileService(this.localSaveMode, this.localSavePath);
    }
}
